/******************************************************************************
* Copyright (c) 2020 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html

* Contributors:
* IBM Corporation - initial API and implementation
******************************************************************************/
package io.openliberty.graphql.sample.client;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;

import io.smallrye.graphql.client.typesafe.api.GraphQlClientBuilder;

@ApplicationPath("/")
@Path("test/client")
@Produces(MediaType.TEXT_PLAIN)
public class JaxrsResource extends Application{

    @GET
    @Path("/{location}")
    public String tempAndPrecipFor(@PathParam("location") String location) {
        WeatherApi api = GraphQlClientBuilder.newBuilder().endpoint("http://localhost:9080/mpGraphQLSample/graphql").build(WeatherApi.class);
        TempAndPrecip tempAndPrecip = api.currentConditions(location);
        return tempAndPrecip.toString();
    }
}